package com.softcloud.gamesbase;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;


public class IntroductionActivity extends BaseActivity {

    private ImageView heroImageImageView;
    private TextView heroNameTextView;
    private TextView heroDesTextView;
    private ListView heroSkillListView;

    public static void actionStart(Context context,Hero hero){
        Intent intent = new Intent(context,IntroductionActivity.class);
        Bundle bundle = new Bundle();
        bundle.putSerializable("hero",hero);
        intent.putExtras(bundle);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_introduction);

        heroImageImageView = (ImageView)findViewById(R.id.hero_image_introduction);
        heroNameTextView = (TextView)findViewById(R.id.hero_name_introduction);
        heroDesTextView = (TextView)findViewById(R.id.hero_des_introduction);
        heroSkillListView = (ListView)findViewById(R.id.hero_skill_list);

        Intent intent = getIntent();
        Hero hero = (Hero)intent.getSerializableExtra("hero");
        heroImageImageView.setImageResource(hero.getHeroImageId());
        heroNameTextView.setText(hero.getHeroName());
        heroDesTextView.setText(hero.getHeroDes());
        SkillAdapter adapter = new SkillAdapter(IntroductionActivity.this,R.layout.hero_skill_item,hero.getSkills());
        heroSkillListView.setAdapter(adapter);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_introduction, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
